package com.itheima.app;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

public class Test_exeJDBC {
    public static void main(String[] args) throws SQLException {
        ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext("exe07-application-CRUD.xml");
        DataSource dataSource = (DataSource) app.getBean("dataSource");
        System.out.println(dataSource.getConnection().isClosed());

        UserMapper userMapper = (UserMapper) app.getBean("userMapper");
        List<User> list = userMapper.findAll();
        for (User user : list) {
            System.out.println(user);
        }
        System.out.println("-----------------------");
        User user = userMapper.findById(1);
        System.out.println(user);
        System.out.println("------------------------");
        User user1 = new User();
    }
}
